package com.wuhunyu.constant;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

/**
 * 微信常量配置
 *
 * @author wuhunyu
 * @version 1.0
 * @date 2021-01-26 19:49
 */
@Component
@ConfigurationProperties(prefix = "weixin.pay")
@PropertySource("classpath:application.yml")
public class WeChatConstant implements InitializingBean {

    /**
     * 关联的公众号
     */
    @Value("${appid}")
    private String appid;

    /**
     * 商户号
     */
    @Value("${partner}")
    private String partner;

    /**
     * 商户号
     */
    @Value("${partnerkey}")
    private String partnerkey;

    /**
     * 商户key
     */
    @Value("${notifyurl}")
    private String notifyurl;

    public static String APP_ID;

    public static String PARTNER;

    public static String PARTNER_KEY;

    public static String NOTIFY_URL;

    @Override
    public void afterPropertiesSet() throws Exception {
        APP_ID = this.appid;
        PARTNER = this.partner;
        PARTNER_KEY = this.partnerkey;
        NOTIFY_URL = this.notifyurl;
    }

}
